		/*****头部和尾部内容*****/
		$('#headbox').load('php/header.php');
		$('#footbox').load('php/footer.php');
		//对选定的表单执行输入验证
		$('#main form').validate({
		  //指定每个输入的验证规则
		  rules:{
			uname: {
			  required:true,
			  //range:[4,12]
			  minlength:4,
			  maxlength:12
			},
			pwd: {
			  required: true,
			  minlength:6,
			  maxlength:18
			},
		  },  
		  //验证失败后的提示信息
		  messages:{
			uname: {
			  required: '用户名不能为空',
			  //range:'用户名在4~12位字符之间'
			  minlength:'用户名在4~12位字符之间',
			  maxlength:'用户名在4~12位字符之间'
			},
			pwd: {
			  required: '密码不能为空',
			  minlength:'密码不少于6位字符',
			  maxlength:'密码不超过18位字符'
			},
		  }
		});
		/*****登录请求******/
		$('#main form [type="button"]').click(function(){
			var n=$('#main form [name="uname"]').val();
			var p=$('#main form [name="pwd"]').val();
			$.getJSON('php/login.php',{'uname':n,'upwd':p},function(data){
				if(data.length>0) {
					//登录成功
					for (var i in data) {
						var d=data[i];
						$('#loginName>li:first-child,#loginName>li:nth-child(2)').empty();
						$('#loginName>li:first-child').append(`
							<span class="uname">${d.uname}</span>欢迎您归来！
						`);
						$('#loginName>li:first-child').css({
							color:'#fff'
						});
						$('#loginName .uname').css({
							color:'#e4393c'
						});
						$('#loginName>li:nth-child(2)').append(`
							<a href = "#" > 安全退出 </a><span>|</span>
						`);
						$('#loginName>li:nth-child(2)>a').css({
							color:'#ffa500',
							paddingLeft:'10px'
						});
					}
					$('#main form input').val('');
					$('head').append(`
						<meta http-equiv='refresh' content='0.2;url=index.html'>
					`);
					// worker session 保持登录
					$.session.set('uname',n);
				}else{
					$('#pwd-error').css({
						display:'none'
					});
					$('#error').css({
						display:'block'
					});
				}
			});
		});
		// 登录失败后获取焦点处理
		$('#main form input').focus(function(){
			$('#error').css({
				display:'none'
			});
		});
